package com.wei.czz.common.enums.store;

import com.wei.czz.common.dto.common.NameValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2023-12-05 09:52:31
 * className: StoreAssignTypeEnum 商店分单方式枚举类
 * version: 1.0
 * description:
 */
@Getter
@AllArgsConstructor
public enum StoreAssignTypeEnum {

    CLAIM(0, "认领"), ASSIGN(1, "分单"),
    ;

    /**
     * 值
     */
    private final Integer value;

    /**
     * 名称
     */
    private final String name;

    /**
     * 获取商店分单方式枚举列表
     * @return 枚举列表
     */
    public static List<NameValue<Integer>> getAssignTypeList() {
        return Stream.of(values())
                .map(assignTypeEnum -> new NameValue<>(assignTypeEnum.getName(), assignTypeEnum.getValue()))
                .collect(Collectors.toList());
    }

    /**
     * 获取枚举对象名称
     * @param value 枚举值
     * @return 名称
     */
    public static String getName(Integer value) {
        for (StoreAssignTypeEnum storeAssignTypeEnum : values()) {
            if (storeAssignTypeEnum.value.equals(value)) {
                return storeAssignTypeEnum.name;
            }
        }
        return "";
    }
}
